# -*- coding:utf-8 -*-
import cv2 as cv


def show_videos(videos_path):
    video = cv.VideoCapture(videos_path)

    # 设置编/解码方式
    fourcc = cv.VideoWriter_fourcc(*'DIVX')

    # cv.VideoWriter()第一种构造函数（两种方法效果相同）
    # result = cv.VideoWriter()
    # result.open('./videos/Save_video.avi', fourcc, 20.0, (640, 480))
    # cv.VideoWriter()第二种构造函数
    result = cv.VideoWriter('./videos/Save_video.avi', fourcc, 20.0, (640, 480))

    # 判断是否成功创建视频流
    while video.isOpened():
        ret, frame = video.read()
        if ret is True:

            cv.imshow('Video_origin', frame)
            cv.waitKey(int(1000 / video.get(cv.CAP_PROP_FPS)))
            # 按下q退出
            if cv.waitKey(1) & 0xFF == ord('q'):
                break
        else:
            break

